<?php
session_start();
require_once 'conexao.php';


 $login = addslashes( $_POST['login'] );

 $senha = md5( $_POST['senha'] );


 $query = mysql_query("SELECT ID FROM usuario WHERE nome='$login' AND senha='$senha'");
 
 $campo = mysql_fetch_array($query);
 


 if ( mysql_num_rows($query)>0 )
 {

	$_SESSION['logado'] = true;

	$_SESSION['id_usuario'] = $campo['ID'] ;

        echo "<script type='text/javascript'>
                document.location.href='\index.php?pagina=inicio'
              </script> ";
 }
 else 
     {

	echo "<script type='text/javascript'>
     alert('Senha ou usuario incorreto! tente novamente!'); document.location.href='\index.php?pagina=login_sistemas'
     </script> ";
     }
   
?>